<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // var arr = [1, 2, 3];
    // var a = arr[0];
    // var b = arr[1];
    // var c = arr[2]
    // 1基本解构赋值
    // var [a, b, c] = arr;
    var [a, c, b] = [1, 2, 3]
    console.log(a, b, c)
    //2嵌套解构 x,y,z
    var [x, [[y], z]] = [5, [[6], 7]]
    console.log(x, y, z)
    // 3.可忽略  m=7 n=9 
    var [m, , n] = [7, 8, 9];
    console.log(m, n)
    // 4.不完全解构 d默认为1
    let [d = 1, s] = [, 8]
    console.log(d, s)
    // 5.剩余运算符 ...
    var [name, age, ...num] = ['老王', '18', 'c', 'd', 'E']
    console.log(name, age)
    console.log(num) //['c', 'd', 'E']
    //6.字符串解构赋值
    let [o, p, q, r, t] = 'hello'
    console.log(o, p, q, r, t)

    let [a = 3, b = a] = [1, 2]  //a=1  b=2

  </script>
</body>

</html>